package trb.complexshield.bool;

import java.util.ArrayList;
import java.util.List;

public class SegmentsMemory {

    private final List<Segments> segmentsList = new ArrayList();
    private int segmentsListSize = 0;
    private final List<List<Segments>> segmentsListList = new ArrayList();
    private int segmentsListListSize = 0;

    public void clear() {
        segmentsListSize = 0;
        segmentsListListSize = 0;
    }

    public Segments newSegments() {
        if (segmentsList.size() <= segmentsListSize) {
            segmentsList.add(new Segments());
        }
        Segments segments = segmentsList.get(segmentsListSize++);
        segments.clear();
        return segments;
    }

    public List<Segments> newSegmentsList() {
        if (segmentsListList.size() <= segmentsListListSize) {
            segmentsListList.add(new ArrayList());
        }
        List<Segments> segmentsList = segmentsListList.get(segmentsListListSize++);
        segmentsList.clear();
        return segmentsList;
    }
}
